<?

/*	TextNewsletter OBJECT
*
*	Info:
*	First priority: unsubscribe!
*
*	Methods:
*	output	-> html string
*	ajax	-> javascript string
*
*	Constructor:
*	
*					*/




class TextNewsletter extends MOD {


#	HTML loop module request	
	public function output() {
		global $Album, $Object;
		
		if( $this->action )
			$nodes = $this->{ "filter_" . $this->action }();
		
		
		if( $nodes ) {
			$this->addclass( $this->action );
			$result = implode( "\n", $nodes );
		}
		
		return ( $result )? $this->parse( $result ) . $this->render_js() : "";
		
	}

	
#	HTML Module.
#	Output actions	

#	Action unsubscribe
	private function filter_unsubscribe() {
		global $DB;
		
		//http://gentjazz.com/info/news?unsubcribe=1&email=koen@onedotonly.be&id=2

		if( $_GET[ 'unsubscribe' ] &&  $id = $DB->get_key( "user", "user=" . $DB->smartq( $_GET[ 'email' ]). " && ID = " . (( int ) $_GET[ 'id' ]), "ID" )) { 

			 $DB->query( "delete from user where ID=$id limit 1", 0 );
			 $lines[] = "<div class='green georgia' >" . translate( "U bent Verwijderd!" ) . "</div>";
			
		} else if( $_GET[ 'unsubscribe' ] )
			 $lines[] = "<div class='red georgia' >" . translate( "Niet gevonden of reeds weg..." ) . "</div>";
		else $lines = false;
	
		return $lines;
	}
	
	
}
?>